import { Observer } from 'mobx-vue'
import { Component, Vue } from 'vue-property-decorator'
import CsjUpload from 'src/views/components/upload/upload.vue'
import { addPaeClass } from 'src/utils/axios';
import { imagesOssPrefix } from "src/utils/ztbase"

@Observer
@Component({
  props: {
    clear: {
      type: Boolean,
      default: false
    }
  },
  components: {
    CsjUpload
  }
})
export default class PaeAdd extends Vue {
  isShowModel: boolean = false;
  formItem:any={
    title: "",
    image: ""
  }
  mounted() {
    let vm: any = this;
    vm.isShowModel = true;
  }
  //关闭
  close() {
    let vm: any = this;
    let xwindow: any = window
    vm.isShowModel = false;
    if (!vm.clear) {
      xwindow.clearBodyStyle()
    }
    vm.$emit('close')
  }
  async confirm() {
    let vm: any = this;
    let xwindow: any = window
    let param={ ...vm.formItem }
    let out:any = await addPaeClass(param);
    if (!out.status) {
          vm.isShowModel = false;
          if (!vm.clear) {
              xwindow.clearBodyStyle()
          }
          vm.$emit('confirm')
    }else {
      vm.$Message.error(out.error.msg)
    }
  }


  // 图片补全前缀
  imagePrefix(url, zoomScale) {
    return imagesOssPrefix(url, zoomScale)
  }
 }
 